package com.ruoyi.graduate.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.graduate.domain.param.MsPhotographyPackageAddParam;
import com.ruoyi.graduate.domain.param.MsPhotographyPackagePageParam;
import com.ruoyi.graduate.domain.param.MsPhotographyPackageUpdataParam;
import com.ruoyi.graduate.domain.param.PageBaseParam;
import com.ruoyi.graduate.service.IMsPhotographyPackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 摄影套餐控制接口
 */
@RestController
@RequestMapping("/api/phpackage")
@Api(tags = "摄影套餐控制接口")
public class MsPhotographyPackageController extends BaseController {

    @Autowired
    private IMsPhotographyPackageService msPhotographyPackageService;


    @ApiOperation("摄影套餐分页查询")
    @GetMapping
    public TableDataInfo list(MsPhotographyPackagePageParam param) {
        PageInfo pageInfo = msPhotographyPackageService.listPage(param);

        return getDataTable(pageInfo.getList(), pageInfo.getTotal());
    }

    @ApiOperation("摄影套餐新增")
    @PostMapping
    public AjaxResult add(@RequestBody MsPhotographyPackageAddParam param){

        return msPhotographyPackageService.add(param);
    }


    @ApiOperation("摄影套餐修改")
    @PutMapping
    public AjaxResult updata(@RequestBody MsPhotographyPackageUpdataParam param){

        return msPhotographyPackageService.updata(param);
    }


    @ApiOperation("摄影套餐删除")
    @DeleteMapping("{id}")
    public AjaxResult delete(@PathVariable("id") Integer id){

        boolean b = msPhotographyPackageService.removeById(id);

        return b ? AjaxResult.success() : AjaxResult.error();
    }


    @ApiOperation("用户端获取套餐列表")
    @GetMapping("/userpageList")
    public TableDataInfo userpageList(PageBaseParam param) {
        PageInfo pageInfo = msPhotographyPackageService.userPageList(param);

        return getDataTable(pageInfo.getList(), pageInfo.getTotal());
    }

}
